<?php $__env->startSection('css'); ?>
    <style>
        .layer-go-back{
            display:none;
        }
    </style>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('title'); ?>
    <li class="cur">
        <span>会员设置</span>
    </li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

    <div class="form-group">
        <label  class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>是否开启充值卡：</label>
        <div class="col-sm-9">
            <div class="layui-form">
                <input type="radio"  name="is_open" lay-filter="is_open" value="0"  title="否" <?php if( !isset($configure['is_open']) || $configure['is_open'] == 0 ): ?> checked <?php endif; ?>>
                <input type="radio"  name="is_open" lay-filter="is_open" value="1"  title="是" <?php if( isset($configure['is_open']) && $configure['is_open'] == 1 ): ?> checked <?php endif; ?>>
            </div>
        </div>
    </div>

    <div class="form-group"  <?php if( !isset($configure['is_open']) || $configure['is_open'] == 0 ): ?> style="display: none" <?php endif; ?>>
        <label class="col-sm-3 control-label" ><span class="red pr5">*&nbsp;</span> 充值卡名称：</label>
        <div class="col-sm-4">
            <input type="text"  name="card_name" id="card_name"  class="form-control" value="<?php if( isset($configure['card_name']) && $configure['card_name'] ): ?> <?php echo e($configure['card_name']); ?> <?php else: ?> 充值卡 <?php endif; ?>">
        </div>
    </div>

    <div class="form-group" <?php if( !isset($configure['is_open']) || $configure['is_open'] == 0 ): ?> style="display: none" <?php endif; ?>>
        <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>核销类型：</label>
        <div class="col-sm-9">
            <div class="layui-form">
                <input type="radio" name="consume_type" lay-filter="is_pay" class="consume_type" value="1" title="线上" checked>
                <input type="radio" name="consume_type" lay-filter="is_pay" class="consume_type"  value="2" title="线下" <?php if( isset($configure['consume_type']) && $configure['consume_type'] == 2): ?> checked <?php endif; ?>>
            </div>
        </div>
    </div>

    <div class="form-group" <?php if( !isset($configure['consume_type']) || $configure['consume_type'] != 2 || !isset($configure['is_open']) || $configure['is_open'] != 1 ): ?> style="display: none" <?php endif; ?>>
        <label class="col-sm-3 control-label"><span class="red pr5">*&nbsp;</span>充值类型：</label>
        <div class="col-sm-9">
            <div class="layui-form">
                <input type="radio" name="is_full_pay" class="is_full_pay" value="1" title="全额冲" checked>
                <input type="radio" name="is_full_pay" class="is_full_pay"  value="2" title="部分冲" <?php if( isset($configure['is_full_pay']) && $configure['is_full_pay'] == 2): ?> checked <?php endif; ?>>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-3 control-label"></label>
        <div class="col-sm-5">
            <input type="hidden" name="function_id" id="function_id" value="<?php echo e(isset($function_id) ? $function_id : ''); ?>">
            <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success">
        </div>
    </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script>

        layui.use(['form'], function(){

            var form = layui.form();

            form.on('radio(is_open)',function(data){
                if ( data.value == 1 ) {
                    $('.form-group:eq(1)').show();
                    $('.form-group:eq(2)').show();
                } else {
                    $('.form-group:eq(1)').hide();
                    $('.form-group:eq(2)').hide();
                }
                var consume_type = $('.consume_type:checked').val();
                if ( consume_type == 2 && data.value == 1) {
                    $('.form-group:eq(3)').show();
                } else {
                    $('.form-group:eq(3)').hide();
                }

            });

            form.on('radio(is_pay)',function(data){
                if ( data.value == 2 ) {
                    $('.form-group:eq(3)').show();
                } else {
                    $('.form-group:eq(3)').hide();
                }

            });

        });

        var func = {

            //保存
            edit:function(){

                var message_log = '' ;
                var configure = E.getFormValues('edit-form') ;

                //参数判断
                if( E.isEmpty( configure.function_id ) || !E.isInt( configure.function_id ) ) {
                    message_log += '参数错误<br/>' ;
                }

                if ( configure.is_open == 1 ) {
                    if( E.isEmpty( configure.card_name ) ) {
                        message_log += '充值卡名称不能为空<br/>' ;
                    }
                } else {
                    configure = {};
                    configure.is_open = 0;
                    configure.function_id = $('#function_id').val();
                }

                if ( configure.consume_type == 1 ) {
                    configure.is_full_pay = '';
                }

                if( message_log ) {
                    layer.alert( message_log , { icon:2 });
                    return false ;
                }

                layer.confirm("您确认保存该设置吗？",{icon:3,offset:'50px'}, function ( index ){
                    layer.close( index );
                    E.ajax( {
                        type:'get',
                        url: '/lar/develop/function/store/'+function_id,
                        data: configure,
                        dataType:'json',
                        // 返回值判断
                        success: function ( obj ){

                            if ( obj.code == 200 ) {
                                layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                            } else {
                                layer.alert( obj.message , { icon: 2 } ) ;
                            }
                        }
                    } ) ;
                });
            }

        }
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('develop.layoutEdit', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>